%{
#define TRUE 1
#define FALSE 0

#define CHAPTER 4

  
int in_section=FALSE;
int in_lisp=FALSE;
int defspec_title=FALSE;
int defmac_title=FALSE;
int in_defmac=FALSE;
int defun_title=FALSE;
int defun_arg=FALSE;
int start_defun_arg=FALSE;
int in_c=FALSE;
int in_chapter=FALSE;
int in_comment=FALSE;
int section_number=TRUE;
int in_setq=FALSE;
int in_setq_noput=FALSE;
char setqstr[64];
char exdent[256];
char section[256];
char dsection[256];
char defmac[256];
char defmac1[256];
char funcname[256];
char base_funcname[256];
char funlink[1280];

char system_exec_str[2560];
char system_exec_str_tmp[2560];
%}


%%
"(compiler)" {
  printf("<a href='compil.html#compiler'>this link</a>"); }
"(compiler-input-section)" {
  printf("<a href='compil.html#compiler-input-section'>this link</a>");}
"(defstruct)" {
    printf("<a href='dfstr.html#defstruct'>this link</a>"); }
"(named-structure)" {
    printf("<a href='dfstr.html#named-structure'>this link</a>"); }
"(array-type)" {
    printf("<a href='fd_arr.html#array-type'>this link</a>"); }
"(indirect-array)" {
    printf("<a href='fd_arr.html#indirect-array'>this link</a>"); }
"(index-offset)" {
    printf("<a href='fd_arr.html#index-offset'>this link</a>"); }
"(cdr-code)" {
    printf("<a href='fd_con.html#cdr-code'>this link</a>"); }
"(alist)" {
    printf("<a href='fd_con.html#alist'>this link</a>"); }
"(locative)" {
    printf("<a href='fd_loc.html#locative'>this link</a>"); }
"(number)" {
    printf("<a href='fd_num.html#number'>this link</a>"); }
"(stack-group)" {
    printf("<a href='fd_sg.html#stack-group'>this link</a>"); }
"(disembodied-property-list)" {
    printf("<a href='fd_sym.html#disembodied-property-list'>this link</a>"); }
"(lambda-list)" {
    printf("<a href='i_lisp.html#lambda-list'>this link</a>"); }
"(tvob)" {
    printf("<a href='jobsys.html#tvob'>this link</a>"); }
"(declaring-packages)" {
    printf("<a href='packd.html#declaring-packages'>this link</a>"); }
"(screen)" {
    printf("<a href='tv.html#screen'>this link</a>"); }
"(pc-ppr)" {
    printf("<a href='tv.html#pc-ppr'>this link</a>"); }

".setq ".*"\n"    {		/* Single */
  sscanf(yytext,"%*6s %s\n",setqstr);
  //  printf("<font color='red'>%s</font>",&setqstr);
  in_setq=TRUE;
}


"'cindex "    {
  if(in_setq)
    {
    printf("<p class='cindent' id='%s'>",&setqstr);
    in_setq=FALSE;
    }
  else
    {
      printf("<p class='cindent'>");
    }

  printf("<!-- ");
  in_comment=TRUE;
}

".cindex "    {
  if(in_setq)
    {
    printf("<p class='cindent' id='%s'>",&setqstr);
    in_setq=FALSE;
    }
  else
    {
      printf("<p class='cindent'>");
    }

  printf("<!-- ");
  in_comment=TRUE;
}

".exdent 96 ".*\n {
  sscanf(yytext,"%*s %*s %s\n",exdent);
  printf("<font class='exdent'>%s</font><!-- exdent -->\n",&exdent);
}

".section ".*\n { 
  sscanf(yytext,"%*s %*[\"]%[^\"]",section);
  printf("<div class='section'>%d.%d %s</div>",CHAPTER,section_number++,&section);
}

".lisp" {
  printf("<pre class=\"lisp\">");
}

".end_lisp" {
  printf("</pre>");
}

".defspec "    {
  printf("<div class=\"defspec\">");
  defspec_title=TRUE;
  printf("<font class='exdent'><font class='funcname'>");
}

".end_defspec"    printf("</div>");


".defmac ".*\n   {
  sscanf(yytext,"%*s %[^\n]",defmac);
  printf("<div class='defmac'>");
  printf("<font class='exdent'>");
  printf("<font class='funcname' id='%s'>%s</font>",&defmac,&defmac);
  printf("<font class=\"italic\"> Macro</font><br>");
  printf("</font><!-- end font_exdent --><br>");
}

".defmac1 ".*\n  {
  printf("</div>");

  sscanf(yytext,"%*s %[^\n]",defmac);
  printf("<div class='defmac'>");
  printf("<font class='exdent'>");
  printf("<font class='funcname' id='%s'>%s</font>",&defmac,&defmac);
  printf("<font class=\"italic\"> Macro</font><br>");
  printf("</font><!-- end font_exdent --><br>");
}

".end_defmac"    printf("</div>");

".defun "    {
  printf("<div class='defun'>");
  defun_title=TRUE;
  printf("<font class='exdent'><font class='funcname'>");
}

".end_defun"    printf("</div>");

"\n" {
  if(defspec_title)
    {
      printf("</font><font class=\"italic\"> Special Form</font></font><br>");
      defspec_title=FALSE;
    } 

  if(in_section)
    {
      printf("</div>\n");
      in_section=FALSE;
    } 
 
  if(defun_arg)
    {
      printf("</font></font></font><br>"); /* funcname ,arg, exdent */
      defun_arg=FALSE;
    } 
  
 
  if(in_comment)
    {
      printf(" -->\n");
      in_comment=FALSE;
    } 
  else
    {
      printf("\n");
    }
}

. {
  if(defun_title && !(strcmp(yytext," ")))
    {
      defun_title=FALSE;
      start_defun_arg=TRUE;
      defun_arg=TRUE;
      printf("%s",yytext);
    }
  else if(start_defun_arg)
    {
      printf("<font class='italic' color='purple'>");
      /*      printf("<font color='purple'>%s</font>",yytext);*/
      start_defun_arg=FALSE;
      printf("%s",yytext);
    }
  else
    {
      printf("%s",yytext);
    }
}  
  
%%
